<template>
	<view class="content">
		<view class="hei20"></view>
		<view v-if="list" class="wid90 mar bacFFF borRad20" style="padding: 40rpx 0;">
			<view class="wid90 mar dis disAl">
				<view style="width: 30%;height: 142rpx;">
					<image :src="url+list.goods.pic" class="hei100" style="width: 142rpx;"></image>
				</view>
				<view class="dis disAl disJuB" style="width: 70%;">
					<view>
						<view class="foSi40 fowe600">{{list.goods.name}}</view>
						<view class="foSi30 mar-top30">×{{list.num}}</view>
					</view>
					<view class="dis disAl disJuC borRad40 foSi30" v-if="list.writeoff_state == 1"
						style="width: 140rpx;height: 52rpx;border: 4rpx solid #035DFF;color: #035DFF;">已核销</view>
					<view class="dis disAl disJuC borRad40 foSi30" v-if="list.writeoff_state == 0"
						style="width: 140rpx;height: 52rpx;border: 4rpx solid #FE6522;color: #FE6522;">未核销</view>
				</view>
			</view>
		</view>
		<view v-if="list" class="wid90 mar bacFFF borRad20 mar-top30 foSi25 fowe600">
			<view style="height: 1rpx;"></view>
			<view class="wid90 mar">
				<view class="mar-top30 dis disAl disJuB">
					<view style="opacity: 0.7;">联系人</view>
					<view style="color: #010101;">{{list.name}}</view>
				</view>
				<view class="mar-top30 dis disAl disJuB">
					<view style="opacity: 0.7;">联系电话</view>
					<view style="color: #010101;">{{list.mobile}}</view>
				</view>
				<view class="wid100 xia mar-top30"></view>
				<view class="mar-top30 dis disAl disJuB">
					<view style="opacity: 0.7;">消耗积分</view>
					<view style="color: #010101;">{{list.integral}}</view>
				</view>
				<view class="mar-top30 dis disAl disJuB">
					<view style="opacity: 0.7;">兑换时间</view>
					<view style="color: #010101;">{{list.createtime}}</view>
				</view>
				<view class="mar-top30 dis disAl disJuB">
					<view style="opacity: 0.7;">兑换单号</view>
					<view style="color: #010101;">{{list.order_num}}</view>
				</view>
				<view v-if="list.writeoff_state == 1" class="wid100 xia mar-top30"></view>
				<view v-if="list.writeoff_state == 1" class="mar-top30 dis disAl disJuB">
					<view style="opacity: 0.7;">核销门店</view>
					<view style="color: #010101;">{{name}}</view>
				</view>
				<view v-if="list.writeoff_state == 1" class="mar-top30 dis disAl disJuB">
					<view style="opacity: 0.7;">核销人</view>
					<view style="color: #010101;">{{list.clerk.name}}</view>
				</view>
				<view v-if="list.writeoff_state == 1" class="mar-top30 dis disAl disJuB">
					<view style="opacity: 0.7;">核销时间</view>
					<view style="color: #010101;">{{dateFormat(list.writeofftime)}}</view>
				</view>
			</view>
			<view style="height: 40rpx;"></view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: this.global.url,
				list: '',
				id: '',
				yuan_userinfo: '',
				name: ''
			}
		},
		onLoad(option) {
			this.yuan_userinfo = uni.getStorageSync('yuan_userinfo')
			this.id = option.id
			this.name = option.name
			this.getList()
		},
		onShow() {},
		methods: {
			dateFormat(time) {
				let date = new Date(time*1000);
				let year = date.getFullYear();
				// 在日期格式中，月份是从0开始的，因此要加0，使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
				let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
				let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
				let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
				let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
				let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
				// 拼接
				return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
				// return year + "-" + month + "-" + day;
			},
			getList() {
				var that = this;
				uni.request({
					url: that.global.url + '/api/qianyu_petrol/gasstation_clerk_write_info',
					method: "POST",
					header: {
						'site-id': that.global.site_id,//自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						id: that.id
					},
					success(res) {
						let result = res.data
						console.log(result)
						if (result.code == 1) {
							that.list = result.data
						}
					}
				})
			},
			tiaozhuan(url) {
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style>
	.content {
		background: #F8F9FD;
		height: 100vh;
	}
	.xia{
		height: 1rpx;
		background-color: #E5E5E5;
	}
</style>
